package utility;

import java.io.FileNotFoundException;
import java.io.RandomAccessFile;
import java.sql.ResultSet;
import dbmanager.DBManager;
import dbmanager.GetIdName;

public class RemoveDuplicateType 
{
	DBManager database;
	String TYPE="type";
	GetIdName gid ;
	public RemoveDuplicateType() 
	{
		database = new DBManager();
		database.getConnect();		
		gid =new GetIdName(database);
		TYPE = gid.getId(TYPE);
	}
	
	public void  RemoveDupictetype(int indexofmid)
	{
		String path = "//home//server//resultset.csv";
		try 
		{
			RandomAccessFile raf =new RandomAccessFile(path,"r");
			String line=raf.readLine();
			while((line=raf.readLine())!=null)
			{
				String splitline[]= line.split(",");
				ResultSet rs = database.getSelect("select * from property_details where mid='"+splitline[indexofmid]+"' and pid='"+TYPE+"'");
				try
				{
					rs.next();
					while(rs.next())
					{
					String id1 = rs.getString("id");
					database.getDelete("delete  from property_details where mid ='"+rs.getString("mid")+"'"+"and pid='"+rs.getString("pid")+"' and pv ='"+rs.getString("pv")+"' and vt='"+rs.getString("VT")+"'"+" and  id="+id1);
					}
				}
				catch (Exception e) 
				{
					e.printStackTrace();
				}
			}
		}
		catch (Exception e) 
		{
			e.printStackTrace();
		}
	}
	public static void main(String[] args) 
	{
		RemoveDuplicateType rdt =new RemoveDuplicateType();
		rdt.RemoveDupictetype(0);
	}
}
